import Vue from 'vue'
import VueRouter from 'vue-router'
import BasicLayout from "@/layout/BasicLayout.vue";
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/app/system/menu',
  },
  {
    path: '/login',
    name: 'Project',
    component: ()=> import("../view/login.vue"),
    // redirect: redirect,
  },
  {
    path:'/app',
    name:"App",
    component:BasicLayout,
    children:[
      {
        path: '/app/home',
        name: 'App-home',
        component: ()=> import("../view/home.vue"),
      },
      {
        path: '/app/system/menu',
        name: 'System-menu',
        component: ()=> import("../view/system/menu.vue"),
      },
      {
        path: '/app/system/dept',
        name: 'System-dept',
        component: ()=> import("../view/system/dept.vue"),
        meta:{
          perms:'system:dept'
        }
      },
      {
        path: '/app/system/role',
        name: 'System-role',
        component: ()=> import("../view/system/role.vue"),
        meta:{
          perms:'system:role'
        }
      },
      {
        path: '/app/system/oper',
        name: 'System-oper',
        component: ()=> import("../view/system/oper.vue"),
      }
    ]
  }
]


// 防止连续点击多次路由报错
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
}

const router = new VueRouter({
  routes
})

export default router